package com.base.service.impl;

import com.base.mapper.voipmapper.RebatePidMapper;
import com.base.po.voip.RebatePid;
import com.base.service.RebatePidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("rebatePidService")
public class RebatePidServiceImpl implements RebatePidService {

    @Autowired
    private RebatePidMapper rebatePidMapper;

    @Override
    public int insert(RebatePid record) {
        return rebatePidMapper.insert(record);
    }

    @Override
    public int insertSelective(RebatePid record) {
        return rebatePidMapper.insertSelective(record);
    }

    @Override
    public String selectByPid(String userid) {
        String pid = rebatePidMapper.selectByPid(userid);
        if (pid == null || pid.isEmpty()) {
            return null;
        }
        if (rebatePidMapper.updateByPid(pid, userid) <= 0) {
            return null;
        }
        return pid;
    }
}
